﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WebAppMatrix.Caching
{
    public  class NoCacheProvider : CacheBase
    {
        #region CacheBase方法

        public override T Get<T>(string key, params object[] keyArgs)
        {
            return default(T);
        }

        public override T Fetch<T>(string key, Func<T> callIfGetReturnsNull, params object[] keyArgs)
        {
            return callIfGetReturnsNull();
        }

        public override T Fetch<T>(string key, Func<T> callIfGetReturnsNull, DateTime absoluteExpiration, params object[] keyArgs)
        {
            return callIfGetReturnsNull();
        }

        public override T Fetch<T>(string key, Func<T> callIfGetReturnsNull, TimeSpan slidingExpiration, params object[] keyArgs)
        {
            return callIfGetReturnsNull();
        }

        public override T Fetch<T>(string key, Action<T> callIfGetReturnsValue, Func<T> callIfGetReturnsNull, params object[] keyArgs)
        {
            var r = callIfGetReturnsNull();
            return r == null ? callIfGetReturnsNull() : r;
        }

        public override T Fetch<T>(string key, Action<T> callIfGetReturnsValue, Func<T> callIfGetReturnsNull, DateTime absoluteExpiration, params object[] keyArgs)
        {
            var r = callIfGetReturnsNull();
            return r == null ? callIfGetReturnsNull() : r;
        }

        public override T Fetch<T>(string key, Action<T> callIfGetReturnsValue, Func<T> callIfGetReturnsNull, TimeSpan slidingExpiration, params object[] keyArgs)
        {
            var r = callIfGetReturnsNull();
            return r == null ? callIfGetReturnsNull() : r;
        }

        public override void Insert(string key, object data, params object[] keyArgs)
        {
            
        }

        public override void Insert(string key, object data, DateTime absoluteExpiration, params object[] keyArgs)
        {
            
        }

        public override void Insert(string key, object data, TimeSpan slidingExpiration, params object[] keyArgs)
        {
            
        }

        public override void Remove(string key, params object[] keyArgs)
        {
            
        }

        public override void RemoveAll()
        {
            
        }

        public override int Count()
        {
            return 0;
        }

        #endregion
    }
}
